package com.javaking.clanteam.hvz.sql;
	
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

/**
 * This is a class designed to be a wrapper to a JSONObject
 * that has all the columns for the SQL server stored in it.
 * @author Scott
 *
 */
public class HVZUser extends JSONObject {
	
	/**
	 * Instantiates a new user based off the JSONObject.
	 *
	 * @param jsonObject the base json object
	 */
	public HVZUser (JSONObject jsonObject) throws JSONException  {
		super(jsonObject, getJSONnames(jsonObject));
	}
	
	/**
	 * Instantiates a new user based off the jsonString.
	 *
	 * @param jsonString the json string
	 * @throws JSONException the jSON exception
	 */
	public HVZUser(String jsonString) throws JSONException 
	{
		super(jsonString);
	}
	
	/**
	 * Instantiates a blank user.
	 */
	public HVZUser()
	{
		super();
	}

	/**
	 * Get all the keys from this object.
	 *
	 * @param jsonObject the json object
	 * @return the keys
	 */
	private static String[] getJSONnames(JSONObject jsonObject) {
		String[] names = new String[jsonObject.length()];
		for (int i = 0; i<jsonObject.length(); i++)
		{
			try {
				names[i] = jsonObject.names().getString(i);
			} catch (JSONException e) {
				Log.e("HvZ",e.toString());
			}
		}
		return names;
	}
	
	
	/**
	 * Gets the id.
	 *
	 * @return the id
	 */
	public String getId() 
	{
		try {
			return getString("id");
		} catch (JSONException e) {
			Log.e("HvZ",e.toString());
			return null;
		}
	}
	
	/**
	 * Sets the id.
	 *
	 * @param id the new id
	 */
	public void setId(String id) 
	{
		try {
			put("id", id);
		} catch (JSONException e) {
			Log.e("HvZ",e.toString());
		}
	}
	
	/**
	 * Gets the barcode.
	 *
	 * @return the barcode
	 */
	public String getBarcode() 
	{
		try {
			return getString("barcode");
		} catch (JSONException e) {
			Log.e("HvZ",e.toString());
			return null;
		}
	}
	
	/**
	 * Sets the barcode.
	 *
	 * @param barcode the new barcode
	 */
	public void setBarcode(String barcode) 
	{
		try {
			put("barcode", barcode);
		} catch (JSONException e) {
			Log.e("HvZ",e.toString());
		}
	}
	
	/**
	 * Gets the username.
	 *
	 * @return the username
	 */
	public String getUsername() 
	{
		try {
			return getString("username");
		} catch (JSONException e) {
			Log.e("HvZ",e.toString());
			return null;
		}
	}
	
	/**
	 * Sets the username.
	 *
	 * @param username the new username
	 */
	public void setUsername(String username) 
	{
		try {
			put("username", username);
		} catch (JSONException e) {
			Log.e("HvZ",e.toString());
		}
	}
	
	/**
	 * Gets the usertype.
	 *
	 * @return the usertype
	 */
	public String getUsertype() 
	{
		try {
			return getString("usertype");
		} catch (JSONException e) {
			Log.e("HvZ",e.toString());
			return null;
		}
	}
	
	/**
	 * Sets the usertype.
	 *
	 * @param usertype the new usertype
	 */
	public void setUsertype(String usertype) 
	{
		try {
			put("usertype", usertype);
		} catch (JSONException e) {
			Log.e("HvZ",e.toString());
		}
	}
	
	/**
	 * Gets the status.
	 *
	 * @return the status
	 */
	public String getStatus() 
	{
		try {
			return getString("status");
		} catch (JSONException e) {
			Log.e("HvZ",e.toString());
			return null;
		}
	}
	
	/**
	 * Sets the status.
	 *
	 * @param status the new status
	 */
	public void setStatus(String status) 
	{
		try {
			put("status", status);
		} catch (JSONException e) {
			Log.e("HvZ",e.toString());
		}
	}
	
	/**
	 * Gets the killcodes assigned.
	 *
	 * @return the killcodes assigned
	 */
	public String getKillcodesAssigned() 
	{
		try {
			return getString("killcodes_assigned");
		} catch (JSONException e) {
			Log.e("HvZ",e.toString());
			return null;
		}
	}
	
	/**
	 * Sets the killcodes assigned.
	 *
	 * @param killcodesAssigned the new killcodes assigned
	 */
	public void setKillcodesAssigned(String killcodesAssigned) 
	{
		try {
			put("killcodes_assigned", killcodesAssigned);
		} catch (JSONException e) {
			Log.e("HvZ",e.toString());
		}
	}
	
	/**
	 * Gets the killcodes acquired.
	 *
	 * @return the killcodes acquired
	 */
	public String getKillcodesAcquired() 
	{
		try {
			return getString("killcodes_acquired");
		} catch (JSONException e) {
			Log.e("HvZ",e.toString());
			return null;
		}
	}
	
	/**
	 * Sets the killcodes acquired.
	 *
	 * @param killcodesAcquired the new killcodes acquired
	 */
	public void setKillcodesAcquired(String killcodesAcquired) 
	{
		try {
			put("killcodes_acquired", killcodesAcquired);
		} catch (JSONException e) {
			Log.e("HvZ",e.toString());
		}
	}
}
